(defun loop-n(p m n)
  (let ((res nil))
    (loop for i from m to n do
	 (setf res (append res (list (nth i p)))))
    res))


(defun list-add-n(p q m n)
  (let ((res nil)(len (length p)))
    (decf m)
    (decf n)
    (if (> m (length p)) (setf m len))
    (if (< m -1) (progn  (setf m (+ len m 1))(if (< m -1) (setf m -1))))
    (setf res (loop-n p 0 m))
    (setf res (append res (loop-n q 0 n)))
    (setf res (append res (loop-n p (1+ m) len)))
    res))

(defun list-add-nil(p m n)
  (list-add-n p nil m n))
(defun list-add(p q m)
  (list-add-n p (list q) m 1))

(defun if2cond(p)
  (let ((len (length p)))
    (if (= len 3)
	(list 'cond (list (nth 1 p) (nth 2 p)))
	(if (= len 4)
	    (list 'cond (list (nth 1 p)(nth 2 p))(list 'T (nth 3 p)))
	    nil))))